﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace yichu_front
{
    public partial class Form_Notice : Form
    {
        bool isOpen = false;
        public Form_Notice()
        {
            InitializeComponent();
        }

        private void Form_Notice_Load(object sender, EventArgs e)
        {
            Notice notice = SqlSugarHelp.scope.Queryable<Notice>().OrderBy(it => it.通告时间, OrderByType.Desc).First();
                this.txt_notice.Text = notice.通告内容;
        }

        private void Form_Notice_FormClosed(object sender, FormClosedEventArgs e)
        {
            foreach (Form item in Application.OpenForms)
            {
                if (item is Form_Main)
                {
                    item.Activate();
                    item.WindowState = FormWindowState.Maximized;
                    isOpen = true;
                    
                    break;
                }
            }
            if (!isOpen)
            {
                Form_Main form_Main = new Form_Main();
                form_Main.Show();
               
            }
        }

        private void btn_submit_Click(object sender, EventArgs e)
        {
            foreach (Form item in Application.OpenForms)
            {
                if (item is Form_Main)
                {
                    item.Activate();
                    item.WindowState = FormWindowState.Maximized;
                    isOpen = true;
                    this.Close();
                    break;
                }
            }
            if (!isOpen)
            {
                Form_Main form_Main = new Form_Main();
                form_Main.Show();
                this.Close();
            }
        }
    }
}
